package game.source.gui.ship;

import game.source.gui.Animation;
import game.source.gui.Explosion;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class GuiEnemyShipTwo extends GuiShip{
	private static Animation anim;	//As imagens do avião do player
	private int frame;
	private static int height;		//altura da imagem
	private static int width;		//largura da imagem
	
	/*Constantes de animação: Indicam em que frame começa e termina cada animação*/
	private final int TURN_LEFT_START 	= 1;
	private final int TURN_LEFT_END 	= 12;
	private final int TURN_RIGHT_START 	= 13;
	private final int TURN_RIGHT_END 	= 24;
	private final int EXPLODE_START		= 25;
	private final int EXPLODE_END		= EXPLODE_START + Explosion.getNumFrames() -1;
	
	static {
		BufferedImage img = null;
		GuiEnemyShipTwo.anim = new Animation();
		for(int c = 0; c < 25 ;c++){
			try{
				img = ImageIO.read(new File(GuiEnemyShipTwo.class.getResource("/images/enemy02/"+c+".png").getFile()));
			}catch (Exception e) {
				e.printStackTrace();
				System.err.println("Arquivo: "+GuiEnemyShipTwo.class.getResource("/images/enemy02/"+c+".png")+" não pode ser aberto");
				System.exit(1);
			}
			GuiEnemyShipTwo.anim.add(img);
		}
		GuiEnemyShipTwo.height = img.getHeight(null);
		GuiEnemyShipTwo.width = img.getWidth(null);
		
		for(int i = 0;i < Explosion.getNumFrames(); i++){
			GuiEnemyShipTwo.anim.add(Explosion.getFrame(i));
		}
		
	}
	
	public GuiEnemyShipTwo(){
		this.frame = 0;
	}
	
	@Override
	public Animation getAnimation(){
		return GuiEnemyShipTwo.anim;
	}
	@Override
	public int getWidth() {
		return GuiEnemyShipTwo.width;
	}
	@Override
	public int getHeight() {
		return GuiEnemyShipTwo.height;
	}
	@Override
	public int getFrame() {
		return this.frame;
	}
	@Override
	public void setFrame(int frame) {
		this.frame = frame;
	}
	
	@Override
	public int getTurnLeftStart() {
		return this.TURN_LEFT_START;
	}
	@Override
	public int getTurnLeftEnd() {
		return this.TURN_LEFT_END;
	}
	@Override
	public int getTurnRightStart() {
		return this.TURN_RIGHT_START;
	}
	@Override
	public int getTurnRightEnd() {
		return this.TURN_RIGHT_END;
	}

	@Override
	public int getExplosionStart() {
		return this.EXPLODE_START;
	}

	@Override
	public int getExplosionEnd() {
		return this.EXPLODE_END;
	}
}
